Skip to content

Comments

feat: add multiple integer types (i8, i16, i32, u8, u16, u32, u64)#113

Open
rvcas wants to merge 3 commits intomainfrom
rvcas/multiple-integer-types
Open

feat: add multiple integer types (i8, i16, i32, u8, u16, u32, u64)#113
rvcas wants to merge 3 commits intomainfrom
rvcas/multiple-integer-types

Conversation

@rvcas
Copy link
Contributor

@rvcas rvcas commented Feb 18, 2026

Summary

  • Add IntWidth enum with 8 variants (I8, I16, I32, I64, U8, U16, U32, U64) and change Type::Int to Type::Int(IntWidth)
  • Integer literals are now polymorphic — they adopt their type from context (annotations, function params) and default to i64 when unconstrained
  • Cross-type arithmetic (e.g. i32 + i64) is a type error; unsigned negation is rejected
  • Wasm codegen uses ValType::I64 for 64-bit types and ValType::I32 for all smaller types with truncation/sign-extension
  • Component ABI store functions filled in for all integer widths
  • Compile-time range checking rejects out-of-range literals (e.g. let x: i8 = 300)
  • Added E0044 error page for LiteralOutOfRange
  • Updated language spec with integer type table and polymorphic literal rules

@rvcas rvcas force-pushed the rvcas/multiple-integer-types branch from 29bf08a to 1261de2 Compare February 18, 2026 22:42
@rvcas rvcas force-pushed the rvcas/multiple-integer-types branch 2 times, most recently from 57f02fe to 2300788 Compare February 19, 2026 17:26
Add IntWidth enum with 8 variants and change Type::Int to
Type::Int(IntWidth). Integer literals are now polymorphic — they get a
fresh type variable constrained to integer types, with the concrete
type determined by context and defaulting to i64. Cross-type arithmetic
(e.g. i32 + i64) is a type error. Unsigned negation is rejected.

Wasm codegen maps i64/u64 to ValType::I64 and all smaller types to
ValType::I32 with appropriate truncation/sign-extension. Component ABI
store functions are filled in for all widths. Overflow checking is
generalized per type.

Signed-off-by: rvcas <x@rvcas.dev>
Signed-off-by: rvcas <x@rvcas.dev>
@rvcas rvcas force-pushed the rvcas/multiple-integer-types branch from 2300788 to 67a6ea5 Compare February 20, 2026 16:49
Signed-off-by: rvcas <x@rvcas.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants